/* Replication do file 2 for "Hostile sexism and overconfidence shape the public's views of climate change"
Analysis and output for Lucid data 
Use Lucid_cleaned.dta 
*/

clear
capture log close
set scheme lean2
use "Lucid_cleaned.dta", clear
set more off

// measures for climate indices
// mitigation policies
factor fossiltax renewableincrease educateclimate reducemilitaryco2, pcf
*gen mitigationprefs=(fossiltax + renewableincrease + educateclimate + reducemilitaryco2)/4
tab mitigationprefs, m
recode mitigationprefs(.=.m)
alpha fossiltax renewableincrease educateclimate reducemilitaryco2
// adaptation
factor disasterfund jobretraining impactfund trainmilitary, pcf
*gen adaptationprefs=(disasterfund + jobretraining + impactfund + trainmilitary)/4
tab adaptationprefs, m
recode adaptationprefs(.=.m)
alpha disasterfund jobretraining impactfund trainmilitary
// individual behaviors to respond to climate change
factor likelybehavior_1 likelybehavior_2 likelybehavior_3 likelybehavior_4, pcf
*gen behaviorprefs=(likelybehavior_1 + likelybehavior_2 + likelybehavior_3 + likelybehavior_4)/4
tab behaviorprefs, m
recode behaviorprefs(.=.m)
alpha likelybehavior_1 likelybehavior_2 likelybehavior_3 likelybehavior_4

************* TABLE 2

eststo clear
logit overconfident hostilesexism [pweight=weight]
estimates store dk1
logit overconfident hostilesexism b3.pid3 [pweight=weight]
estimates store dk2
logit overconfident hostilesexism b3.pid3 education Male [pweight=weight]
estimates store dk3
logit overconfident hostilesexism b3.pid3 education Male knowledgescale misinfo [pweight=weight]
estimates store dk4

esttab dk1 dk2 dk3 dk4 using "table2b.rtf", replace cells(b(star fmt(3)) se(par fmt(3))) stats(N pr2, labels("N. of cases") fmt(0)) label legend varlabels(_cons Constant)

************* TABLE 3

eststo clear
reg knowledgescale hostilesexism b3.pid3 [pweight=weight]
estimates store knowledge1
reg knowledgescale hostilesexism b3.pid3 education Male [pweight=weight]
estimates store knowledge2
reg misinfo hostilesexism b3.pid3 [pweight=weight]
estimates store misinfo1
reg misinfo hostilesexism b3.pid3 education Male [pweight=weight]
estimates store misinfo2

esttab knowledge1 knowledge2 misinfo1 misinfo2 using "table3lucid.rtf", replace cells(b(star fmt(3)) se(par fmt(3))) stats(N r2, labels("N. of cases") fmt(0)) label legend varlabels(_cons Constant)

eststo sexism:  margins, at(hostilesexism=(1(1)5))  atmeans post

coefplot (sexism, label (LUCID Sample)), ///
	xtitle ("Sexism") ///
	ytitle ("Meta Ignorance") ///
	title ("") ///
	at recast(line) lwidth(*2) ciopts(recast(rline) lc(gray) lp(-) lw(vthin)) ///
	xlab(1 "Low" 3 "Medium" 5 "High", labsize(small))

************* FIGURE 1: RIGHT PANEL

logit overconfident hostilesexism b3.pid3 education Male knowledgescale misinfo [pweight=weight]
eststo sexism:  margins, at(hostilesexism=(1(1)5))  atmeans post

coefplot (sexism, label (LUCID Sample)), ///
	xtitle ("Sexism") ///
	ytitle ("Meta Ignorance") ///
	title ("Lucid") ///
	at recast(line) lwidth(*2) ciopts(recast(rline) lc(gray) lp(-) lw(vthin)) ///
	xlab(1 "Low" 3 "Medium" 5 "High", labsize(small)) ///
	ylab(0 "0%" .25 "25%" .5 "50%", labsize(small)) ///
		
	graph save "Lucid.gph", replace	
	graph export "LUCID_sexism.png", replace width(1800)


************* Appendix: Correlation matrix
asdoc pwcorr overconfidence hostilesexism knowledgescale misinfo Democratic Republican education Male, replace
asdoc pwcorr overconfidence hostilesexism knowledgescale misinfo Democratic Republican education Male, sig star(0.05) replace

